<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/views/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>后台-角色详情</title>
	<link rel="stylesheet" href="<%=path%>/css/bootstrap/3.3.5/css/bootstrap.min.css" />
	<link rel="stylesheet" href="<%=path%>/css/cropper.min.css" />
	<link rel="stylesheet" href="<%=path%>/css/cz.css" />
	<script src="<%=path%>/js/jquery-1.11.0.min.js"></script>
	<script src="<%=path%>/js/plugins/layer/layer.js"></script>
<body class="gray-bg">
<jsp:include page="/views/base/commons/header.jsp"/>
<div class="container page-single">
	<div class="col-md-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title">角色详情</h3>
			</div>
			<div class="panel-body event-create">
				<input type="hidden" name="roleId"  id="role_id"  value="${roleVO.roleId}">
				<div class="form-group">
					<label  class="col-sm-1 control-label">
						角色名称
					</label>
					<div class="col-sm-5" style="padding-top: 7px;">
						${roleVO.roleName}
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="container usercenter">
	<div class="panel panel-default mt20">
		<div class="panel-body">
			<div class="col-sm-6 base-nav"  id="has_permission_list_div">
				<div class="panel-heading">
					<h3 class="panel-title">已获取的权限列表</h3>
				</div>
				<div class="bd clearfix">
					<form id="role_permission_has_form" action="javascript:void(0);">
						<input type="hidden" name="type" id="list_type_has" value="1">
					</form>
				</div>
			</div>
			<div class="col-sm-6"  id="not_own_permission_list_div">
				<div class="panel-heading">
					<h3 class="panel-title">未获取的权限列表</h3>
				</div>
				<div class="bd clearfix">
					<form id="role_permission_not_own_form" action="javascript:void(0);">
						<input type="hidden" name="type" id="list_type_not_own" value="2">
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<jsp:include page="/views/base/commons/footer.jsp"></jsp:include>
<script type="text/javascript" >
	$(function() {
		queryRolePermissionList_has(1);
		queryRolePermissionList_not_own(1);
	})

	function queryRolePermissionList_has(pageNo){
		var roleId=$("#role_id").val();
	
		var queryData = $("#role_permission_has_form").serialize();
	
		if (queryData == null || queryData == "") {
			queryData = "pageNo=" + pageNo+"&roleId="+roleId;
		} else {
			queryData = queryData + "&pageNo=" + pageNo+"&roleId="+roleId;
		}
		$.ajax({
			url : path + "/base/role/rolePermissionList",
			type : "get",
			dataType : "html",
			data : queryData,
			async:false,
			success : function(data) {
				$("#has_permission_list_div").html(data);
			},
			error : function() {
				layer.msg("服务器网络繁忙", {
					icon : 2
				});
			}
		});
	}
	function queryRolePermissionList_not_own(pageNo){
		var roleId=$("#role_id").val();
		
		var queryData = $("#role_permission_not_own_form").serialize();

		if (queryData == null || queryData == "") {
			queryData = "pageNo=" + pageNo+"&roleId="+roleId;
		} else {
			queryData = queryData + "&pageNo=" + pageNo +"&roleId="+roleId;
		}
		$.ajax({
			url : path + "/base/role/rolePermissionList",
			type : "get",
			dataType : "html",
			async:false,
			data : queryData,
			success : function(data) {
				$("#not_own_permission_list_div").html(data);
			},
			error : function() {
				layer.msg("服务器网络繁忙", {
					icon : 2
				});
			}
		});
	}
	
	function deleteRolePermission(permissionId){
		var roleId=$("#role_id").val();
		$.ajax({
			url : path + "/base/role/deleteRolePermission",
			type : "post",
			dataType : "json",
			data : {
				roleId : roleId,
				permissionId : permissionId
			},
			success : function(data)
			{
				if(data.result){
					layer.msg(data.message,{icon: 1});
					queryRolePermissionList_has(1);
					queryRolePermissionList_not_own(1);
				}else{
					layer.msg(data.message,{icon: 2});
				}
			},error:function(){
				layer.msg("服务器网络繁忙",{icon: 2});
			}
		});
	}
	
	function addRolePermission(permissionId){
		var roleId=$("#role_id").val();
		$.ajax({
			url : path + "/base/role/insertRolePermission",
			type : "post",
			dataType : "json",
			data : {
				roleId : roleId,
				permissionId : permissionId
			},
			success : function(data)
			{
				if(data.result){
					layer.msg(data.message,{icon: 1});
					queryRolePermissionList_has(1);
					queryRolePermissionList_not_own(1);
				}else{
					layer.msg(data.message,{icon: 2});
				}
			},error:function(){
				layer.msg("服务器网络繁忙",{icon: 2});
			}
		});
	}
</script>
</body>
</html>